package com.sky.config;

import com.sky.properties.MinIoProperties;
import com.sky.utils.MinIoUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * minio配置类
 */
@Configuration
@Slf4j
public class MinIoConfiguration {
    @Bean
    @ConditionalOnMissingBean //条件对象当没有这个类的时候就会去创建此类
    public MinIoUtil minIoUtil(MinIoProperties minIoProperties) {
        log.info("minio初始化...");
        log.info("minio配置参数为:{}", minIoProperties);
       return new MinIoUtil(
                minIoProperties.getEndpoint(),
                minIoProperties.getAccessKey(),
                minIoProperties.getSecretKey(),
                minIoProperties.getBucketName());
    }
}
